<!DOCTYPE html>
<html lang="en" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8"/>
    <title>腾飞健康管理平台</title>
    <link rel="stylesheet" href="css/oksub.css">
</head>
<body style="padding: 10px">

<div class="layui-btn-container">
    <shiro:hasPermission name="registe">
        <button type="button" class="layui-btn" id="registeUserBtn">挂号</button>
    </shiro:hasPermission>

    <shiro:hasPermission name="charge">
        <button type="button" class="layui-btn" id="chargeBtn">缴费</button>
    </shiro:hasPermission>

    <shiro:hasPermission name="fillInfo">
        <button type="button" class="layui-btn" id="fillInInfoBtn">填写信息</button>
    </shiro:hasPermission>

    <shiro:hasPermission name="totalExamine">
        <button type="button" class="layui-btn" id="totalExamineBtn">总检</button>
    </shiro:hasPermission>
</div>


<script type="text/javascript" src="lib/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(["jquery"], function () {
        let $ = layui.jquery;

        //跳转到挂号页面
        $("#registeUserBtn").on("click", function () {
            window.open("/registeUser", "_top");
        });

        //跳转到缴费页面
        $("#chargeBtn").on("click", function () {
            window.open("/charge", "_top");
        });

        //总检
        $("#totalExamineBtn").on("click", function () {
            window.open("/totalExamine", "_top");
        });

        //填写信息
        $("#fillInInfoBtn").on("click", function () {
            window.open("/fillInfo", "_top");
        });

        //获取按钮组标题列表
        $.ajax({
            url: "/getTypeLevel1List",
            dataType: "json",
            type: "get",
            async: true,
            success: function (responseData) {
                console.log(responseData);
                for (let i = 0; i < responseData.length; i++) {
                    $(".layui-btn-container").append("<button type='button' class='layui-btn' id=" + responseData[i].itemTypeId + ">" + responseData[i].typeName + "</button>");
                    if (responseData[i].typeName === "实验室检查") {
                        console.log(responseData[i].typeName + "\t" + i);
                        $("#" + responseData[i].itemTypeId).on("click", function () {
                            window.open("/laboratory", "_top");
                        });
                    } else if (responseData[i].typeName === "放射类检查") {
                        console.log(responseData[i].typeName + "\t" + i);
                        $("#" + responseData[i].itemTypeId).on("click", function () {
                            window.open("/radiology", "_top");
                        });
                    } else if (responseData[i].typeName === "窥镜类检查") {
                        console.log(responseData[i].typeName + "\t" + i);
                        $("#" + responseData[i].itemTypeId).on("click", function () {
                            window.open("/speculum", "_top");
                        });
                    } else if (responseData[i].typeName === "超声类检查") {
                        console.log(responseData[i].typeName + "\t" + i);
                        $("#" + responseData[i].itemTypeId).on("click", function () {
                            window.open("/supersonic", "_top");
                        });
                    } else if (responseData[i].typeName === "医技类检查") {
                        console.log(responseData[i].typeName + "\t" + i);
                        $("#" + responseData[i].itemTypeId).on("click", function () {
                            window.open("/medical", "_top");
                        });
                    } else if (responseData[i].typeName === "临床类检查") {
                        console.log(responseData[i].typeName + "\t" + i);
                        $("#" + responseData[i].itemTypeId).on("click", function () {
                            window.open("/clinic", "_top");
                        });
                    }
                }
            },
            error: function () {
                console.log("获取项目类型level=1的数据列表请求失败！")
            }
        });


    });
</script>
</body>
</html>